package com.yxhl.zoume.domain.interactor.updateapp;

import com.yxhl.zoume.data.http.repository.updateapp.UpdateAppRepository;
import com.yxhl.zoume.data.http.rest.param.CheckUpdateParam;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.response.login.CheckUpdateResponse;
import com.yxhl.zoume.domain.DomainConstants;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by Xboy on 16/3/17.
 */
public class CheckAppVersionUseCase extends com.yxhl.zoume.domain.interactor.base.UseCase<CheckUpdateResponse> {
    private final UpdateAppRepository repository;

    @Inject
    public CheckAppVersionUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                  @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                  UpdateAppRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    public Observable<CheckUpdateResponse> buildObservable(RequestParamImpl param) {
        return repository.checkUpdate((CheckUpdateParam) param)
                .observeOn(uiThread)
                .subscribeOn(executorThread);
    }
}
